package com.gss.armory.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name="DOC_TYPE_DTLS")
public class DocumentTypeDTO implements Serializable {
	
	
	private Integer dtId;
	@NotBlank
	private String dtName;
	@NotBlank
	private String dtCode;
	
	private List<DocumentCategoryDTO> dtCategoryList;
	private List<DocumentMetaDataAttributesDTO> dtAttrList = new ArrayList<DocumentMetaDataAttributesDTO>();
	

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="DT_ID")
	public Integer getDtId() {
		return dtId;
	}
	@Column(name="DT_NAME",nullable=false,length=76,unique=true)
	public String getDtName() {
		return dtName;
	}
	@Column(name="DT_CODE",nullable=false,length=21,unique=true)
	public String getDtCode() {
		return dtCode;
	}
	@OneToMany(targetEntity=DocumentCategoryDTO.class,mappedBy="dcParentType")
	@LazyCollection(value=LazyCollectionOption.FALSE)
	public List<DocumentCategoryDTO> getDtCategoryList() {
		return dtCategoryList;
	}
//	@ManyToMany(targetEntity=DocumentMetaDataAttributesDTO.class,fetch=FetchType.EAGER)
//	@JoinTable(name="DOC_TYPE_METADATA_ATTR_MAPPING",joinColumns=@JoinColumn(name="DTM_TYPE_ID"),inverseJoinColumns=@JoinColumn(name="DTM_ATTR_ID"))
	@Transient
	public List<DocumentMetaDataAttributesDTO> getDtAttrList() {
		return dtAttrList;
	}
	
	public void setDtId(int dtId) {
		this.dtId = dtId;
	}
	public void setDtName(String dtName) {
		this.dtName = dtName;
	}
	public void setDtCode(String dtCode) {
		this.dtCode = dtCode;
	}
	public void setDtCategoryList(List<DocumentCategoryDTO> dtCategoryList) {
		this.dtCategoryList = dtCategoryList;
	}
	public void setDtAttrList(List<DocumentMetaDataAttributesDTO> dtAttrList) {
		this.dtAttrList = dtAttrList;
	}

	public void setDtId(Integer dtId) {
		this.dtId = dtId;
	}
	

}
